package com.zjut.azhen.DBDesign.service;

import com.zjut.azhen.DBDesign.bean.Role;
import com.zjut.azhen.DBDesign.bean.User;
import com.zjut.azhen.DBDesign.mapping.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;



    public User getUserById(String id) {
        User user = userMapper.loadUserByUsername(id);
        if (user == null) {
            //避免返回null，这里返回一个null，在后期的密码比对过程中一样会验证失败
            return new User();
        }
        Role role=userMapper.getRoleById(id);
        return user;
    }
    public Role getRoleById(String id){
        return userMapper.getRoleById(id);
    }
}
